package immutablecollections.misc;

/**
 * 
 */
public class StopWatch
{
     private long t;
     private long total;

     public StopWatch()
     {
          t = System.nanoTime();
     }

     public long getElapsedMicroseconds()
     {
          return (total + System.nanoTime() - t) / 1000;
     }

     public long getElapsedMilliseconds()
     {
          return getElapsedMicroseconds() / 1000;
     }

     public long getElapsedSeconds()
     {
          return getElapsedMilliseconds() / 1000;
     }

     public void reset()
     {
          t = System.nanoTime();
          total = 0;
     }

     public void pause()
     {
          total += System.nanoTime() - t;
     }

     public void resume()
     {
          t = System.nanoTime();
     }
}
